﻿Imports System.IO

Public Class FrmAdmin

    Private ruta As String = Application.StartupPath & "/data"

    Private Sub FrmAdmin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'txtRuta.Text = ruta
        Form1.Hide()
    End Sub

    Private Sub btnConsolidar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsolidar.Click
        FolderBrowserDialog1.Description = "Ingrese la ruta donde se encuentren los archivos Personal*.sdf"
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveFileDialog1.FileName = "Personal_consolidado.mdb"
            SaveFileDialog1.Filter = "Archivos MDB (*.mdb)|*.mdb"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                ruta = FolderBrowserDialog1.SelectedPath

                Dim files As String()
                files = Directory.GetFiles(ruta, "*.sdf")
                contexto.personalService.consolidar(files, SaveFileDialog1.FileName)
            End If
        End If
    End Sub

    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
        Me.Hide()
        Form1.Show()
    End Sub

    Private Sub btnEvalCurso_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEvalCurso.Click
        FolderBrowserDialog1.Description = "Ingrese la ruta donde se encuentren los archivos EvalCurso*.mdb"

        'contexto.evalCursoInstructorService.consolidarEvaluacionCurso("d:/", "d:/curso.mdb")
        'Return

        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveFileDialog1.FileName = "EvaluacionCurso_Consolidado.mdb"
            SaveFileDialog1.Filter = "Archivos MDB (*.mdb)|*.mdb"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                contexto.evalCursoInstructorService.consolidarEvaluacionCurso(FolderBrowserDialog1.SelectedPath, SaveFileDialog1.FileName)
            End If
        End If

    End Sub

    Private Sub btnEvalInstructor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEvalInstructor.Click
        FolderBrowserDialog1.Description = "Ingrese la ruta donde se encuentren los archivos EvalInstructor*.mdb"

        'contexto.evalCursoInstructorService.consolidarEvaluacionInstructor("d:/", "d:/instructor.mdb")
        'Return

        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            SaveFileDialog1.FileName = "EvaluacionInstructor_Consolidado.mdb"
            SaveFileDialog1.Filter = "Archivos MDB (*.mdb)|*.mdb"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                contexto.evalCursoInstructorService.consolidarEvaluacionInstructor(FolderBrowserDialog1.SelectedPath, SaveFileDialog1.FileName)
            End If
        End If
    End Sub
End Class